export function post(url, req, callback) {

    $.ajax({
        url: url,
        type: "post",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        async: true,
        data: req,
        success: function(data) {
            console.log("=============" + url + "===========\n" + JSON.stringify(data, null, 2))
            if (data.code == 200) {
                callback.success(data.data)
            } else {
                callback.fail(data.msg)
            }
        },
        error: function(xhr, errorType, error) {
            //   console.log("网络错误")
            callback.fail("网络错误")
        }
    });
}

export function get(url, req, callback) {

    $.ajax({
        url: url,
        type: "get",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        async: true,
        data: req,
        success: function(data) {
            console.log("=============" + url + "===========\n" + JSON.stringify(data, null, 2))
            if (data.code == 200) {
                callback.success(data.data)
            } else {
                callback.fail(data.msg)
            }
        },
        error: function(xhr, errorType, error) {
            //   console.log("网络错误")
            callback.fail("网络错误")
        }
    });
}